import request from '@/utils/request'

// 查询追溯记录列表
export function listTraceRecord(query) {
  return request({
    url: '/mes/traceability/record/list',
    method: 'get',
    params: query
  })
}

// 查询追溯记录详细
export function getTraceRecord(traceId) {
  return request({
    url: '/mes/traceability/record/' + traceId,
    method: 'get'
  })
}

// 新增追溯记录
export function addTraceRecord(data) {
  return request({
    url: '/mes/traceability/record',
    method: 'post',
    data: data
  })
}

// 修改追溯记录
export function updateTraceRecord(data) {
  return request({
    url: '/mes/traceability/record',
    method: 'put',
    data: data
  })
}

// 删除追溯记录
export function delTraceRecord(traceId) {
  return request({
    url: '/mes/traceability/record/' + traceId,
    method: 'delete'
  })
}

// 导出追溯记录
export function exportTraceRecord(query) {
  return request({
    url: '/mes/traceability/record/export',
    method: 'post',
    data: query
  })
}

// 根据工单ID查询追溯记录
export function getTraceRecordByWorkOrder(workOrderId) {
  return request({
    url: '/mes/traceability/record/workOrder/' + workOrderId,
    method: 'get'
  })
}

// 根据批次号查询追溯记录
export function getTraceRecordByBatch(batchCode) {
  return request({
    url: '/mes/traceability/record/batch/' + batchCode,
    method: 'get'
  })
}

// 根据产品ID查询追溯记录
export function getTraceRecordByProduct(productId) {
  return request({
    url: '/mes/traceability/record/product/' + productId,
    method: 'get'
  })
}

// 根据追溯类型查询记录
export function getTraceRecordByType(traceType) {
  return request({
    url: '/mes/traceability/record/type/' + traceType,
    method: 'get'
  })
}

// 校验追溯编码唯一性
export function checkTraceCodeUnique(data) {
  return request({
    url: '/mes/traceability/record/checkTraceCodeUnique',
    method: 'post',
    data: data
  })
}

// 批量新增追溯记录
export function batchInsertTraceRecord(data) {
  return request({
    url: '/mes/traceability/record/batch',
    method: 'post',
    data: data
  })
}